import Opt from '@/components/dt/info/Opt.js'
import table from '@/components/dt/table/render.js'

class DetailColumn extends Opt {

  constructor(name, change) {
    super()
    this.name = name
    this.change = change
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
        type: 'index',
        title: '序号',
        minWidth: 50,
        fixed: 'left'
      },
      {
        field: 'orBonusMonth',
        title: '奖金发放月份',
        minWidth: 120,
        fixed: 'left'
      },
      {
        field: 'houseName',
        title: '项目名称',
        minWidth: 160,
        fixed: 'left'
      },
      {
        field: 'shouldBonusAmount',
        title: '已发奖金(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'bonusPool',
        title: '月度计提(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'issueType',
        title: '发放类型',
        minWidth: 150
      },
      {
        field: 'yearSettlementAmount',
        title: '年底结算奖金(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'systemAdjust',
        title: '系统调整值(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'adjustAmount',
        title: '年底调整金额(元)',
        minWidth: 150,
        slots: {
          default: ({ row }, h) => {
            return table.cell.input(null, h, {
              key: 'adjustAmount',
              data: row,
              type: 'number',
              placeholder: '请输入年底调整金额',
              disabled: this.name != 'yearendEdit',
              blur: () => {
                this.change(row)
              },
            })
          }
        }
        // cell: (item) => {
        //   return {
        //     edit: {
        //       placeholder: '请输入年底调整金额',
        //       disabled: this.name != 'yearendEdit',
        //       input: {
        //         type: 'number',
        //         blur: () => {
        //           this.change(item)
        //         }
        //       }
        //     }
        //   }
        // }
      },
      {
        field: 'adjustReason',
        title: '调整原因',
        minWidth: 160,
        slots: {
          default: ({ row }, h) => {
            return table.cell.input(null, h, {
              key: 'adjustReason',
              data: row,
              placeholder: '请输入调整原因',
              disabled: this.name != 'yearendEdit',
              blur: () => {
                this.change(row)
              },
            })
          }
        }
        // cell: (item) => {
        //   return {
        //     edit: {
        //       placeholder: '请输入调整原因',
        //       disabled: this.name != 'yearendEdit',
        //       input: {
        //         blur: () => {
        //           this.change(item)
        //         }
        //       }
        //     }
        //   }
        // }
      },
      {
        field: 'oaNubmber',
        title: 'OA文电编号',
        minWidth: 160,
        slots: {
          default: ({ row }, h) => {
            return table.cell.input(null, h, {
              key: 'oaNubmber',
              data: row,
              placeholder: '请输入OA文电编号',
              disabled: this.name != 'yearendEdit'
            })
          }
        }
        // cell: (item) => {
        //   return {
        //     edit: {
        //       placeholder: '请输入OA文电编号',
        //       disabled: this.name != 'yearendEdit',
        //       input: {},
        //     }
        //   }
        // }
      },
      {
        field: 'shouldYearBonusAmount',
        title: '年底应发奖金(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'systemBonusPool',
        title: '年底系统计提(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'adjustBonusPool',
        title: '年底计提调整(元)',
        minWidth: 160,
        slots: {
          default: ({ row }, h) => {
            return table.cell.input(null, h, {
              key: 'adjustBonusPool',
              data: row,
              type: 'number',
              placeholder: '请输入年底计提调整',
              disabled: this.name != 'yearendEdit',
              blur: () => {
                this.change(row)
              },
            })
          }
        }
        // cell: (item) => {
        //   return {
        //     edit: {
        //       placeholder: '请输入年底计提调整',
        //       disabled: this.name != 'yearendEdit',
        //       input: {
        //         type: 'number',
        //         blur: (val) => {
        //           this.change(item)
        //         }
        //       }
        //     }
        //   }
        // }
      },
      {
        field: 'actualBonusPool',
        title: '年底实际计提(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'actualBonusAmount',
        title: '年底实发(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
    ]
  }

}

export default DetailColumn